{% extends "approval/base.html" %}
{% block title %} 更新申请 {% endblock %}
{% block content %}
    <style>
        ul.errorlist li {
            color: red;
        }
    </style>
    <div class="col-lg-6 col-lg-offset-3">
        <section class="panel panel-default">
            <div class="panel-heading">
                更新申请
                {% if form.errors %}
                    <div style="color:red">
                        {{ form.errors }}
                        您提交的数据有误,请认真检查!
                    </div>
                {% endif %}
            </div>
            <div class="panel-body" style="padding: 10px;">
                <form class="form-horizontal" method="post" action="{{ request.path }}?t={{ request.GET.t }}&s={{ request.GET.s }}&g={{ request.GET.g }}&search={{ request.GET.search }}"
                      enctype="multipart/form-data">
                    {% csrf_token %}
                    <input type="hidden" name="updated_by" id="id_updated_by" value="{{ request.user.id }}">
                    <input type="hidden" name="status" id="id_status" value="1">
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.date_of_occurrence.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.date_of_occurrence }}
                            <p class="help-block">{{ form.date_of_occurrence.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.dates.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.dates }}
                            <p class="help-block">{{ form.dates.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.related_project.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.related_project }}
                            <p class="help-block">{{ form.related_project.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.related_department.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.related_department }}
                            <p class="help-block">{{ form.related_department.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.name.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.name }}
                            <p class="help-block">{{ form.name.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.initial_amount.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.initial_amount }}
                            <p class="help-block">{{ form.initial_amount.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.initial_notes.label_tag }}</div>
                        <div class="col-lg-10">
                            {{ form.initial_notes }}
                            <p class="help-block">{{ form.initial_notes.errors }}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 control-label">{{ form.has_invoice.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.has_invoice }}
                            <p class="help-block">{{ form.has_invoice.errors }}</p>
                        </div>
                        <div class="col-lg-2 control-label">{{ form.default_approved_by.label_tag }}</div>
                        <div class="col-lg-4">
                            {{ form.default_approved_by }}
                            <p class="help-block">{{ form.default_approved_by.errors }}</p>
                        </div>
                    </div>
                    <section class="attachments">
                        <legend>附件</legend>
                        {{ attachments_formset.management_form }}
                        {{ attachments_formset.non_form_errors }}
                        {% for form in attachments_formset %}
                            <div class="panel">
                                <div class="panel-body">
                                    {{ form.as_p }}
                                </div>
                            </div>
                        {% endfor %}
                    </section>
                    <div class="form-group">
                        <div class="col-lg-12 text-right">
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
{% endblock %}
{% block this_js %}
    <script>
        $('#id_date_of_occurrence').datepicker({language: "zh-CN"});
    </script>
{% endblock %}